]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
St: Take the cairo fallback for large corners
authorJasper St. Pierre <jstpierre@mecheye.net>
Mon, 16 May 2011 23:02:24 +0000 (19:02 -0400)
committerJasper St. Pierre <jstpierre@mecheye.net>
Sat, 9 Jul 2011 22:05:07 +0000 (18:05 -0400)
The cogl path pads the corners out to the maximum corner radius to make the
math and painting logic easier. Unfortunately, when the radius exceeds the
actor's halfsize, the padding ends up interfering with other corners, creating
a big mess of rendering errors.

It'd be extremely complicated to fix this properly in the Cogl code,
so take the Cairo fallback.

https://bugzilla.gnome.org/show_bug.cgi?id=649513

src/st/st-theme-node-drawing.c

index fdef350931d9c9711a1bed3fb4eef00383a8d1e3..a600179a45597c79875125cef1225777f92da061 100644 (file)
@@ -1330,6 +1330,7 @@ st_theme_node_render_resources (StThemeNode   *node,
   gboolean has_border;
   gboolean has_border_radius;
   gboolean has_inset_box_shadow;
+  gboolean has_large_corners;
   StShadow *box_shadow_spec;
   StShadow *background_image_shadow_spec;
   const char *background_image;
@@ -1367,6 +1368,27 @@ st_theme_node_render_resources (StThemeNode   *node,
   else
     has_border_radius = FALSE;
 
+  /* The cogl code pads each corner to the maximum border radius,
+   * which results in overlapping corner areas if the radius
+   * exceeds the actor's halfsize, causing rendering errors.
+   * Fall back to cairo in these cases. */
+  has_large_corners = FALSE;
+
+  if (has_border_radius) {
+    guint border_radius[4];
+    int corner;
+
+    st_theme_node_reduce_border_radius (node, border_radius);
+
+    for (corner = 0; corner < 4; corner ++) {
+      if (border_radius[corner] * 2 > height ||
+          border_radius[corner] * 2 > width) {
+        has_large_corners = TRUE;
+        break;
+      }
+    }
+  }
+
   /* Load referenced images from disk and draw anything we need with cairo now */
   background_image = st_theme_node_get_background_image (node);
   border_image = st_theme_node_get_border_image (node);
@@ -1387,7 +1409,8 @@ st_theme_node_render_resources (StThemeNode   *node,
 
   /* Use cairo to prerender the node if there is a gradient, or
    * background image with borders and/or rounded corners,
-   * since we can't do those things easily with cogl.
+   * or large corners, since we can't do those things
+   * easily with cogl.
    *
    * FIXME: if we could figure out ahead of time that a
    * background image won't overlap with the node borders,
@@ -1395,7 +1418,8 @@ st_theme_node_render_resources (StThemeNode   *node,
    */
   if ((node->background_gradient_type != ST_GRADIENT_NONE)
       || (has_inset_box_shadow && (has_border || node->background_color.alpha > 0))
-      || (background_image && (has_border || has_border_radius)))
+      || (background_image && (has_border || has_border_radius))
+      || has_large_corners)
     node->prerendered_texture = st_theme_node_prerender_background (node);
 
   if (node->prerendered_texture)